package com.ez.supervise.dao.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.ez.supervise.core.Page;
import com.ez.supervise.dao.CmsDao;
import com.ez.supervise.dao.base.BaseDaoImpl;
import com.ez.supervise.model.biz.Cms;

public class CmsDaoImpl extends BaseDaoImpl implements CmsDao {

    public void insert(Object cms) {
	sqlMapClientTemplate.insert("biz.insertCms", cms);
    }

    public Object get(Long id) {
	return (Cms) sqlMapClientTemplate.queryForObject("biz.getCmsById", id);
    }

    public void update(Object org) {
	sqlMapClientTemplate.update("biz.updateCms", org);
    }

    public void delete(Long id) {
	sqlMapClientTemplate.update("biz.deleteCms", id);
    }

    /*
     * (non-Javadoc)
     * 
     * @see com.ez.supervise.dao.CmsDao#findByCount(com.ez.supervise.core.Page)
     */
    public int findCmsByCount(Page page) {
	return (Integer) getSqlMapClientTemplate().queryForObject("biz.findCmsByCount", page.getConditions());
    }

    /*
     * (non-Javadoc)
     * 
     * @see com.ez.supervise.dao.CmsDao#findByPage(com.ez.supervise.core.Page)
     */
    public List findCmsByPage(Page page) {
	return getSqlMapClientTemplate().queryForList("biz.findCmsByPage", page.getConditions());
    }

    /*
     * (non-Javadoc)
     * 
     * @see com.ez.supervise.dao.CmsDao#findAll()
     */
    public List findAll() {
	return getSqlMapClientTemplate().queryForList("biz.findAll");
    }

    public List findCmsByPublish() {
	return getSqlMapClientTemplate().queryForList("biz.findCmsByPublish");
    }

    public void publish(Long id, String publishStatus) {
	Map map = new HashMap();
	map.put("id", id);
	map.put("status", publishStatus);
	getSqlMapClientTemplate().update("biz.publishCms", map);
    }

}
